<?php

namespace App\Listeners\Message;

use App\Common\Libs\Dispatch\Queue;
use App\Consts\GlobalQueueConst;
use App\Events\Message\ReadAnnounceEvent;
use App\Jobs\Controller\MessageJob;
use App\Listeners\BaseListener;

class ReadAnnounceListener extends BaseListener
{
    /**
     * Handle the event.
     *
     * @param ReadAnnounceEvent $event
     * @return bool
     */
    public function handle(ReadAnnounceEvent $event)
    {
        $params = $event->params;
        if (empty($params['announce_user_id'])) {
            $params['announce_user_id'] = [];
        }

        $this->saveFileLog(__CLASS__, $event);

        Queue::getInstance(MessageJob::class)
            ->push($params, GlobalQueueConst::MESSAGE_CHANGE_ANNOUNCE_READ);

        return true;
    }
}
